package top.banner.usercenter.rocketmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.stereotype.Service;
import top.banner.usercenter.domain.dto.messaging.UserAddBonusMsgDTO;
import top.banner.usercenter.service.user.UserService;

import javax.annotation.Resource;

/**
 * @author XGL
 */
@Service
@Slf4j
public class AddBonusStreamConsumer {

    @Resource
    private UserService userService;


    @StreamListener(Sink.INPUT)
    public void receive(UserAddBonusMsgDTO message) {
        log.info("通过stream收到了消息：messageBody = {}", message);

        userService.addBonus(message);

        log.info("积分添加完毕...");
    }
}
